#include <bits/stdc++.h>
using namespace std;
int a[200005],c[200005],co[200005];
int n,res;
void dfs(int d){
    if(d>n){
        for(int i=1;i<=n;i++){
            for(int j=i-1;j>=1;j--){
                if(co[j]==co[i]){
                    if(a[j]==a[i]){
                        c[i]=a[i];
                    }
                    break;
                }
            }
        }
        int ans=0;
        for(int i=1;i<=n;i++){
            ans+=c[i];
        }
        res=max(res,ans);
        return;
    }
    dfs(d+1);
    co[d]=1;
    dfs(d+1);
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t;
    cin>>t;
    while(t--){
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        dfs(1);
        cout<<res<<endl;
    }
    return 0;
}